package org.wmq.organizationmanagement.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
import org.wmq.organizationmanagement.mapper.MemberFileMapper;
import org.wmq.organizationmanagement.model.po.MemberFile;
import org.wmq.organizationmanagement.model.vo.MemberFileVO;
import org.wmq.organizationmanagement.service.MemberFileService;

import java.util.List;


@Service
@RequiredArgsConstructor
@Slf4j
public class MemberFileServiceImpl extends ServiceImpl<MemberFileMapper,MemberFile> implements MemberFileService {

    @Override
    public MemberFileVO getByMemberId(Long memberId) {
        List<MemberFile> memberFileList = this.lambdaQuery().eq(MemberFile::getMemberId, memberId).list();
        if (memberFileList == null){
            log.error("未查到任何会员文件");
            return null;
        }
        List<String> fileUrls = memberFileList.stream().map(memberFile -> memberFile.getUrl()).toList();
        MemberFileVO memberFileVO = new MemberFileVO();
        memberFileVO.setFileUrls(fileUrls);
        return memberFileVO;

    }
}
